package net.xiduth.game.player.content.events.raiding;

import java.util.TimerTask;

import net.xiduth.cores.CoresManager;
import net.xiduth.game.World;
import net.xiduth.game.WorldTile;
import net.xiduth.game.npc.NPC;
import net.xiduth.utils.Logger;

/**
 * 
 * @author Jae <jae@xiduth.com>
 * 
 * @since <Oct 17, 2013>
 *
 */
public class BossRespawnEvent {
	
	public static void load() {
		respawnIceDemon();
	}
	
	public static void respawnIceDemon() {
		CoresManager.fastExecutor.schedule(new TimerTask() {
			@Override
			public void run() {
				try {
					refreshDemon();
					World.sendWorldMessage("<img=7><col=FF000>News: The Ice Demon has respawned.", false);
					World.spawnNPC(14261, new WorldTile(2407, 3887, 0), -1,
							true, true);
					Logger.log("Respawn Event", "Ice demon spawned.");
				} catch (Throwable e) {
					Logger.handle(e);
				}
			}
			}, 0, 900000);
	}
	
	public static final void refreshDemon() {
		for (NPC n : World.getNPCs()) {
			if (n == null || n.getId() != 14261)
				continue;
			n.sendDeath(n);
		}
		Logger.log("Ice Demon", "Refresh complete.");
	}	
}